#!/bin/bash
set -e

function info() {
echo Usage: `basename $0` 'file_path name_list'

cat <<info
info
exit 65
}


while getopts ":p:" opts
do
case $opts in
p) out_prefix=$OPTARG;;
\?) info;;
esac
done
shift $(($OPTIND - 1))

test $# -lt 2 && info



. /mnt/ilustre/app/medical/tools/.var

:<<!
for name in $(cat $2); do
 
	# i=0
	# for r in $(ls ${1}/*${dir}*); do
	# let i+=1

	# cd $dir && ln -s $r ${dir}_atgc_L001_R${i}_001.fq.gz && cd -
	
	# done
	if test `ls $1 |grep "${name}_" |grep '_R1.f' |wc -l` -eq 1; then
		mkdir $name
		r1=$1/`ls $1 |grep "${name}_" |grep '_R1.f'`
		r2=$1/`ls $1 |grep "${name}_" |grep '_R2.f'`
		echo $r1 $r2
		ln -s $r1 $name/${name}_ATCG_L000_R1_000.fastq.gz
		ln -s $r2 $name/${name}_ATCG_L000_R2_000.fastq.gz
		
	fi
	
# snp_0202.sh -s$name -i$3 $name
	
done
!

:>$out_prefix.list.txt

for name in $(cat $2);do
find $1 -type d -name "*${name}*" >> $out_prefix.list.txt
done
